@model  CleverCMS.Cms.Services.ViewModels.MenuItemAddModel
@section TitleContent
{
    @((Model.MenuItem != null && Model.MenuItem.Id != 0) ? "Edit MenuItem" : "New MenuItem")
}
@section HeadContent
{
    <script type="text/javascript" src="@Url.Content("~/areas/clevercms.admin/scripts/custom/menu_edit.js")"></script>
}

<div class="widget green">
    <div class="widget-title">
        <h4><i class="icon-reorder"></i>Menu</h4>
    </div>
    <div class="widget-body">

        <div id="failureResult" class="alert alert-block alert-error" style="display: none">
            <h4 class="alert-heading">Error!</h4>
            <p id="errortext">
            </p>
        </div>

        <div class="alert alert-block alert-success" style="display: none" id="successResult">
            <h4 class="alert-heading">Success!</h4>
            <p>
                Items was successfully saved.
            </p>
        </div>

        @using (Ajax.BeginForm("Edit", "MenuItem", new AjaxOptions { HttpMethod = "POST", OnFailure = "failureSave", OnSuccess = "successSave" }, new { id = "editMenuItemForm", @class = "search_form general_form" }))
        {
            @Html.HiddenFor(x => x.MenuItem.Id)
            @Html.HiddenFor(x => x.MenuItem.CreatedAt)

            <div class="container-fluid">
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Title:</p>
                    </div>
                    <div class="span10">
                        @Html.TextBoxFor(x => x.MenuItem.Title, new { @class = "text large" })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Menu Type:</p>
                    </div>
                    <div class="span10">
                        @Html.DropDownList("MenuItem.MenuId", Model.MenuTypes)
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Menu Parent:</p>
                    </div>
                    <div class="span10">
                        @Html.DropDownList("MenuItem.ParentId", Model.MenuItems, "none")
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <label class="pull-right">Icon:</label>
                    </div>
                    <div class="span10">
                        @Html.TextBoxFor(model => model.MenuItem.Icon)
                    </div>
                    <div id="pictures_block">
                        <span class="icon" value=""></span>
                        @{
                            foreach (string icon in Model.Icons)
                            {
                                <span class="icon" value="@icon"><i class="icon-@icon"></i></span>
                            }
                        }
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Is external URL:</p>
                    </div>
                    <div class="span10">
                        @Html.CheckBoxFor(x => x.MenuItem.IsExternalUrl)
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Visible:</p>
                    </div>
                    <div class="span10">
                        @Html.CheckBoxFor(x => x.MenuItem.Visible)
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Navigate URL:</p>
                    </div>
                    <div class="span10">
                        @Html.TextBoxFor(x => x.MenuItem.NavigateUrl, new { @class = "text large" })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Page ID:</p>
                    </div>
                    <div class="span10">
                        @Html.DropDownList("MenuItem.EntryId", Model.Entries, "none")
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span1 min-px">
                        <p class="pull-right">Sort order:</p>
                    </div>
                    <div class="span10">
                        @Html.TextBoxFor(x => x.MenuItem.SortOrder)
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span11 offset1">
                        <div class="submit_link">
                            <button type="submit" class="btn btn-success" name="save_menu"><i class="icon-ok icon-white"></i>Save</button>
                            <button class="btn btn-inverse" onclick="resetFields(this); return false;"><i class="icon-refresh icon-white"></i>Reset</button>
                            <button class="btn btn-inverse" onclick="history.back()"><i class="icon-ban-circle icon-white"></i>Back</button>
                        </div>
                    </div>
                </div>
            </div>
        }
    </div>
</div>
